/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.gitee.minimalismstyle.fresh.flowable.api.feign

import org.springframework.web.bind.annotation.*
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.flowable.api.annotation.FlowableClient
import com.gitee.minimalismstyle.fresh.flowable.api.config.FlowableFeignConfig
import com.gitee.minimalismstyle.fresh.flowable.api.feign.fallback.DatabasetablesApiFallback
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.DataResponse
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.TableMetaData
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.TableResponse

/**
 * Databasetables
 * @author maoxiaodong
 */
@FlowableClient(configuration = [FlowableFeignConfig::class], fallback = DatabasetablesApiFallback::class)
interface DatabasetablesApi {


    /**
     *  List tables
     */
    @GetMapping("/management/tables")
    fun listTables(
    ): R<Any>

    /**
     * Get a single table
     */
    @GetMapping("/management/tables/{tableName}")
    fun getTable(
        @PathVariable("tableName") tableName: String
    ): R<TableResponse>

    /**
     * Get column info for a single table
     */
    @GetMapping("/management/tables/{tableName}/columns")
    fun getTableMetaData(
        @PathVariable("tableName") tableName: String
    ): R<TableMetaData>

    /**
     * Get row data for a single table
     */
    @GetMapping("/management/tables/{tableName}/data")
    fun getTableData(
        @PathVariable("tableName") tableName: String,
        @RequestParam(name = "start", required = false) start: Int?,
        @RequestParam(name = "size", required = false) size: Int?,
        @RequestParam(name = "orderAscendingColumn", required = false) orderAscendingColumn: String?,
        @RequestParam(name = "orderDescendingColumn", required = false) orderDescendingColumn: String?
    ): R<DataResponse<Map<String, Any>>>
}